// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class FollowCamera extends cc.Component {

   
        @property(cc.Node)
        private followNode:cc. Node = null; // 需要跟随相机移动的节点
    
        @property(cc.Node)
        private followNode2:cc. Node = null;
        
    
        update(deltaTime: number) {
            // 获取场景中的主相机
            const mainCamera =  this.node.getComponent(cc.Camera);
            if (mainCamera && this.followNode&&this.followNode2) {
                // 每一帧更新跟随节点的位置为相机的位置
                this.followNode.setPosition(mainCamera.node.position);
                this.followNode2.setPosition(mainCamera.node.position);
            }
        }
    }
